#include "Roads.h"

void Roads::Generate(Terrain* t,std::vector<GameObject*>* g)
{
	m_pvGameobjects = g;
	m_Wasp = new Wasp(t->GetFractal(),t->GetCellSize());
	m_Wasp->GenerateWeights();
}
void Roads::CreateRoad(D3DXVECTOR2 start, D3DXVECTOR2 end)
{
	HRESULT hr;
	LPD3DXMESH mesh;
	std::vector<D3DXVECTOR2> v= m_Wasp->FindPath(start,end);
	//create mesh for the road
	V(D3DXCreateMesh(v.size()-2,v.size(),D3DXMESH_MANAGED,TheD3DApp::Instance()->GetVertexElements(),TheD3DApp::Instance()->GetD3DDev(),&mesh));


	GameObject* res = new GameObject(mesh);
	m_pvGameobjects->push_back(res);
}